<?php

namespace api\app\validate;

use think\Validate;

class UsersValidate extends Validate
{
    protected $rule = [
        'image' => 'require',
        'user_name' => 'require',
        'mobile' => 'require|length:11|unique:user',
        'code' => 'require|length:4', // 验证码不能为空且必须为4位
    ];

    protected $message = [
        'image.require' => '图片不能为空',
        'user_name' => '用户不存在',
        'mobile.require' => '手机号不能为空',
        'mobile.length' => '手机号必须为11位',
        'mobile.unique' => '手机号重复使用',
        'code.require' => '验证码不能为空', // 验证码不能为空
        'code.length' => '验证码必须为4位', // 验证码长度为4位
    ];

    protected $scene = [
        'register' => ['mobile','code'],
        'login' => ['mobile','code'],
         'add' => ['image'],
         'edit' => ['user_name','mobile','account_type']
    ];
}